import Vue from 'vue'
import App from './App.vue'
import './plugins/element.js'
import router from './router'
import './assets/css/glob.css'
import axios from 'axios'
import Treetable from 'vue-table-with-tree-grid'
//富文本编辑器
import vueQuillEditor from 'vue-quill-editor'
//富文本编辑器样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.config.productionTip = false
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
//注册组件
Vue.component('tree-table', Treetable)
//注册组件
Vue.use(vueQuillEditor)
Vue.filter('timefilter', function (timedata) {
  const dt = new Date(timedata)
  const y = dt.getFullYear()
  // 将月份转换成字符串 
  // padStart判断字符串的位数 如果不足两位就补零
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')
  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  return `${y}-${m}-${d} ${hh}时${mm}分`
})
Vue.prototype.$http = axios

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
